/**
 * Copyright © 2020 易久批信息技术有限公司. All rights reserved.
 */
package com.dysm.single;

import java.util.concurrent.CountDownLatch;

/**
 * 测试单例模式，懒汉式，饿汉式，双重检测锁，静态内部类，枚举
 * @author xiay
 * @since 2020/12/5 9:18 下午
 */
public class SingleClient {

    public static void main(String[] args) throws InterruptedException {
        CountDownLatch latch = new CountDownLatch(5);
        long begin = System.currentTimeMillis();
        for (int i = 0; i < 5; i++) {
            new Thread(() -> {
                for (int j = 0; j < 10000000; j++) {
                    StaticInnerClassModel instance = StaticInnerClassModel.getInstance();
                }
                latch.countDown();
            }).start();
        }

        latch.await();
        long end = System.currentTimeMillis();
        System.out.println("总耗时：" + (end - begin));
    }
}
